package com.configclient.db;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: ResourceConfig
 * @Auther: CLEE
 * @Date: 2018/9/28 11:38
 * @Description: TODO
 * @Copyright: 2018 www.yimidida.com Inc. All rights reserved.
 */
@RestController
@RefreshScope
public class ResourceController{

    @Value("${spring.datasource.url}")
    private String url;

    @Value("${spring.datasource.username}")
    private String username;

    @Value("${spring.datasource.password}")
    private String password;

    @Value("${spring.datasource.driverClassName}")
    private String driverClassName;


    @PostMapping("/test")
    public Map<String,String> dataSource(){
        Map<String,String> map=new HashMap<>();
        map.put("spring.datasource.url",url);
        map.put("spring.datasource.username",username);
        map.put("spring.datasource.password",password);
        map.put("spring.datasource.driverClassName",driverClassName);
        return map;
    }
}
